<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type">
<title><?php echo $data['add'] ? '商品添加' : '商品修改'?></title>

<?php include VIEWS.'admin/style.html'?>
<?php include VIEWS.'admin/script.html'?>

<script type="text/javascript">
<!--
function open_attr() {$('attr_detail','attr_titleopen').invoke('show');$('attr_titleclose').hide()}
function close_attr() {$('attr_detail','attr_titleopen').invoke('hide');$('attr_titleclose').show()}
<?php if($data['cols']):?>window.onload=open_attr;<?php endif;?>
//-->
</script>

<?php include VIEWS.'validation.html'?>

<script type="text/javascript">
<!--
var aa = ajaxStart('post');
var timer = null;

function item_update() {
    $('submit').disabled = true;
    var f = $('updateform');
    aa.call('itemsedit.php?id=<?php echo $data["id"]?>', 'ajaxadminEdit', itemupdate_result, $('updateform').serialize());
    return false;
}

function itemupdate_result(result) {
    var i;
    var d = $('updatemsg');
    try {
        i = (result.result[0].data == 1 ? '更新成功' : '<font color=FFFF66>更新失败</font>，请检查您填写的资料完整性后再提交');
    } catch(e) {
        i = '服务器错误，请稍候再试';
        d.style.backgroundColor= '#FF99FF';
    }

    $('submit').disabled = false;
    d.innerHTML = '&nbsp;&nbsp;&nbsp;' + i + '……';
    d.show();
    new Effect.Round('div', 'updatemsg');
    //location.href="#top";
    if (timer) window.clearTimeout(timer);
    timer = window.setTimeout("$('updatemsg').hide()", 10000);
}

function tagset(tag) {
    tag = $F('tags')+' '+tag;
    $('tags').value = tag;
}

function tagfor(name) {
    var tag = 'for:'+name;
    tagset(tag);
}

//-->
</script>

</head>

<body>

<a name="top" />

<?php include VIEWS.'admin/head.html'?>

<ul id="submenu">
	<li><a href='items.php'>商品列表</a></li>
	<li><a href='itemsedit.php?add=1'<?php if($_GET['add']):?> class="current"<?php endif?>>新增商品</a></li>
	<li><a href='itemscats.php'>商品分类</a></li>
    <li><a href='alert.php'>商品需求</a></li>
</ul>

<div id="body">

<div class="updatemsg" id="updatemsg" style="font-weight:bold;background-color:#FFCC66;font-size:12px;width:80%;display:none;">&nbsp;</div>

<form action="" method="post" id="updateform" enctype="multipart/form-data">
<p class="submit"><input type="submit" value="更新产品信息" style="font-weight:bold" id="submit">&nbsp;<input type="reset" value="重置" style="font-weight:bold">

<table width="75%"><tr><td>

<fieldset>
<legend>销售状态</legend>
<span style="background-color:green;color:#FFF;padding:4px"><input<?php if($data['issale']!=='0') echo ' checked'?> name="issale" type="radio" value="1" id="s0" /><label for="s0">正常销售</label></span>&nbsp;&nbsp;
<span style="background-color:#999;color:#FFF;padding:4px"><input<?php if($data['issale']=='2') echo ' checked'?> name="issale" type="radio" value="2" id="s0" /><label for="s0">隐身销售</label></span>&nbsp;&nbsp;
<span style="background-color:red;color:#FFF;padding:4px"><input<?php if($data['issale']==='0') echo ' checked'?> name="issale" type="radio" value="0" id="s1" /><label for="s1">下架商品</label></span> &nbsp; (注：下架商品不会在列表中出现)
</fieldset>

<fieldset>
<legend>商品名称</legend>
<div><input title="商品名不为能空" type="text" class="required" name="name" value="<?php echo $data['name']?>" style="font-size:1.5em;width:96%;margin:5px"></div>
</fieldset>

<fieldset>
<legend>商品分类</legend>
<small><b>主分类</b></small>
<select name="pid1" title="商品主分类必选" class="validate-selection">
<option>请选择该商品所属主分类</option>
<?php foreach($cats['list'] as $v):?>
<optgroup label="<?php echo $v['name']?>">
<?php foreach($v['list'] as $vv):?>
<option value="<?php echo $vv['id']?>"<?php if($mycats[0]==$vv['id']) echo ' selected';?>>- <?php echo $vv['name']?></option>
<?php endforeach;?>
</optgroup>
<?php endforeach;?>
</select>
&nbsp;&nbsp;
<small><b>次分类</b></small>
<select name="pid2">
<option value="0">请选择该商品所属次分类</option>
<?php foreach($cats['list'] as $v):?>
<optgroup label="<?php echo $v['name']?>">
<?php foreach($v['list'] as $vv):?>
<option value="<?php echo $vv['id']?>"<?php if($mycats[1]==$vv['id']) echo ' selected';?>>- <?php echo $vv['name']?></option>
<?php endforeach;?>
</optgroup>
<?php endforeach;?>
</select>
</fieldset>

<fieldset>
<legend>商品Tags - <i>多个用空格隔开</i></legend>
<input title="Tags 能不为空" class="required" id="tags" type="text" name="tags" size="100" value="<?php echo $data['tags']?>" /><br />
&nbsp; &nbsp; <a title="男朋友" href="javascript:tagfor('him')">for:him</a> - <a title="女朋友" href="javascript:tagfor('her')">for:her</a> - <a title="儿童" href="javascript:tagfor('kids')">for:kids</a> - <a title="父亲" href="javascript:tagfor('dad')">for:dad</a> - <a title="母亲" href="javascript:tagfor('mom')">for:mom</a> - <a title="朋友" href="javascript:tagfor('friends')">for:friends</a> - <a title="情侣" href="javascript:tagfor('lovers')">for:lovers</a>
</fieldset>

<fieldset>
<legend>商品主图 - <i>必填</i></legend>
<b>小图(150*150,gif)</b>：<input type="file" name="pic[s]" /> &nbsp; 
<b>中图(220*220,jpg)</b>：<input type="file" name="pic[m]" />
</fieldset>

<fieldset>
<legend>商品详细资料 - <i>必填</i></legend>
<table class="reportV2" cellpadding="5" width="60%" cellspacing="0">
<tr><td nowrap><b>型号</b></td><td style="text-align:left"><input type="text" name="model" value="<?php echo $data['model']?>"> - 保持为空则自动编号</td></tr>
<tr><td nowrap><b>材质</b></td><td style="text-align:left"><input title="材质不为能空" class="required"  type="text" name="stuff" value="<?php echo $data['stuff']?>"></td></tr>
<tr><td nowrap><b>数量</b></td><td style="text-align:left"><input title="数量不为能空" class="required" type="text" name="stocknum" value="<?php echo $data['stocknum']?>"></td></tr>
<tr><td nowrap><b>进货价</b></td><td style="text-align:left"><input title="进货价不为能空" class="required" type="text" name="pricein" value="<?php echo $data['pricein']?>"></td></tr>
<tr><td nowrap><b>零售价</b></td><td style="text-align:left"><input title="零售价不为能空" class="required"  type="text" name="price1" value="<?php echo $data['price1']?>"></td></tr>
<?php if(!$data['add']):?><tr><td nowrap><b>创建时间</b></td><td style="text-align:left"><?php echo date('Y-m-d H:i',$data['updated'])?></td></tr><?php endif?>
</table>
</fieldset>

<fieldset>
<legend>商品描述 - <i>必填</i></legend>
<?php
include ROOT.'scripts'.DS.'FCKeditor'.DS.'fckeditor.php';
$oFCKeditor = new FCKeditor('desc') ;
$oFCKeditor->ToolbarSet = 'Basic1';
$oFCKeditor->Width = '100%';
$oFCKeditor->Height = 480;
$oFCKeditor->BasePath = '/scripts/FCKeditor/';
$oFCKeditor->Value = $data['desc'] ;
$oFCKeditor->Create() ;
?>
</fieldset>

<fieldset>
<legend>商品分组 - <i>可选</i></legend>
组名：<input type="text" name="groupkey" size="20" value="<?php echo $data['groupkey']?>" />
&nbsp;
属性：<input type="text" name="groupvalue" size="20" value="<?php echo $data['groupvalue']?>" />
</fieldset>

<fieldset>
<legend>商品详细资料 - <i style="font-weight: normal">可选</i></legend>
<table class="reportV2" cellpadding="5" width="60%" cellspacing="0">
<tr><td nowrap>商品描述</td><td style="text-align:left"><input type="text" name="title" value="<?php echo $data['title']?>"></td></tr>
<tr><td nowrap style="color:Blue">商品原价</td><td style="text-align:left"><input type="text" name="price2" value="<?php echo $data['price2']?>"></td></tr>
<tr><td nowrap>代销价</td><td style="text-align:left"><input type="text" name="price3" value="<?php echo $data['price3']?>"></td></tr>
<tr><td nowrap>浏览数</td><td style="text-align:left"><input type="text" name="views" value="<?php echo $data['views']?>"></td></tr>
<tr><td nowrap style="color:Red">附加运费</td><td style="text-align:left"><input type="text" name="postfee" value="<?php echo $data['postfee']?>"></td></tr>
</table>
</fieldset>

<div id="attr_titleclose"><h2><img src="/images/icon_arrow_right.gif"><a href="#" onclick="javascript:open_attr();return false">输入个性属性</a> - <i style="font-weight: normal">可选</i></h2></div>
<div id="attr_titleopen" style="display:none"><h2><img src="/images/icon_arrow_down.gif"><a href="#" onclick="javascript:close_attr();return false">关闭个性属性</a> - <i style="font-weight: normal">可选</i></h2></div>
<div id="attr_detail" style="display:none">
<br />
<table class="reportV2" cellpadding="5" width="60%" cellspacing="0">
<tr class="columntitle" style="text-align:center"><td style="text-align:center">属性名称</td><td style="text-align:center">属性值</td></tr>
<tr><td><input type="text" name="key1" value="<?php echo $data['cols']['key1']?>"></td><td><input type="text" name="val1" value="<?php echo $data['cols']['val1']?>"></td></tr>
<tr><td><input type="text" name="key2" value="<?php echo $data['cols']['key2']?>"></td><td><input type="text" name="val2" value="<?php echo $data['cols']['val2']?>"></td></tr>
<tr><td><input type="text" name="key3" value="<?php echo $data['cols']['key3']?>"></td><td><input type="text" name="val3" value="<?php echo $data['cols']['val3']?>"></td></tr>
<tr><td><input type="text" name="key4" value="<?php echo $data['cols']['key4']?>"></td><td><input type="text" name="val4" value="<?php echo $data['cols']['val4']?>"></td></tr>
<tr><td><input type="text" name="key5" value="<?php echo $data['cols']['key5']?>"></td><td><input type="text" name="val5" value="<?php echo $data['cols']['val5']?>"></td></tr>
</table>

</td></tr></table>

<p class="submit"><input type="submit" value="更新产品信息" style="font-weight:bold" id="submit">&nbsp;<input type="reset" value="重置" style="font-weight:bold">
</form>

<br />
<br />

<script type="text/javascript">
    new Validation('updateform',{useTitles:true,stopOnFirst:true});
</script>

<?php include VIEWS.'admin/runtime.html'?>

</div>

<script type="text/javascript">
$('am3').addClassName('current');
</script>

</body>
</html>
